package keating;

import com.google.gdata.client.douban.DoubanService;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 *
 * @author Keating
 */
public class LoginInfo {
    
    private static final String file = "logininfo";
    
    /**
     * write,序列化
     */
    public void write(Object obj) throws FileNotFoundException, IOException {
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
        out.writeObject(obj);
        out.close();
    }
    
    /**
     * read,反序列化
     */
    public DoubanService read() throws IOException, ClassNotFoundException {
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
        DoubanService service = (DoubanService) in.readObject();
        in.close();
        return service;
    }
    
}
